<?php


use Nette\Application\UI\Presenter;
use Nette\Security;

abstract class BasePresenter extends Presenter
{
	protected function startup()
	{
		parent::startup();

		if($this->getName() !== 'Sign'){
	        if($this->user->isLoggedIn()){
            } else {
                $this->redirect('Sign:in');
            }
		}
    }

    /**
     * before Render
     *
     */
    public function beforeRender()
    {
        if ($this->isAjax()) {
            $this->invalidateControl('flashMessages');
        }
    }

    /**
    * handle logout
    */
    public function handleLogout()
    {
        $this->getUser()->logout(TRUE);
        $this->redirect('Sign:in');
    }
}
